<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@include file="../../common/operation_forbid.jsp" %>
<%@include file="../../common/jsVersion.jsp"%>
<c:set var="contextPath" value="${pageContext.request.contextPath}"/>
<script type="text/javascript">
    var contextPath = '${contextPath}';
    var jypath = contextPath;
    var subscribeId='${subscribeId}';
    var documentType=${documentType};
    var processFlag='${processFlag}';
    var userName="${userName}";
    var returnUrl = '${returnUrl}';
    var roomStatus = '${roomStatus}';
    var shouStatus = '${shouStatus}';
    var auditStatus = '${auditStatus}';
    var busAutoStatus = '${busAutoStatus}';
    var procInstId= '${procInstId}';
    var businessStatus = '${businessStatus}';
    var businessAbnormaId = '${businessAbnormaId}';
    var huanStatus = '${huanStatus}'; 
    var yanqiStatus = '${yanqiStatus}'; 
    var amountDetail = '${amountDetail}';
    var busProcInstId = '${busProcInstId}';
    var returnBackParam= '${busProcInstId}';
    var returnBackParam= '${returnBackParam}';
    var payDepositOff=${payDepositOff};
    var projectId = "";
    var oldSubId = '${oldSubId}';
</script>
<!DOCTYPE html >
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>认购详情</title>
    <!-- neptune -->
    <%@include file="../../common/extInclude.jsp" %>
    <script type="text/javascript" src="${contextPath}/static/js/jquery/jquery-2.0.3.min.js"></script>
    <script type="text/javascript" src="${contextPath}/static/js/customer/subscribe/view.js?v=${jsVersion}"></script>
	<script type="text/javascript" src="${contextPath}/static/js/components/processHistory.js?v=${jsVersion}"></script>
	<script type="text/javascript" src="${contextPath}/static/js/components/processApproval.js?v=${jsVersion}"></script>
	<script type="text/javascript" src="${contextPath}/static/js/components/fileComponent.js?v=${jsVersion}"></script>
	<script type="text/javascript" src="${contextPath}/static/js/jquery/json2.js"></script> 
    <script type="text/javascript">
    	//认购收款、签约、换房
    	var menu = '${menu}';
	  	var idata = '${permitBtn}';
	  	if(idata!=null||idata!=""){
			idata=JSON.parse(idata);
		}
	  	
	  	var marketingSubscribeReceivables = true 
	  	var marketingSignedAdd = true; 
	  	var marketingSubscribeChangeHouse = true ;
	  	var marketingSubscribeShou = true;
	  	var tuiSubscribe = true;
	  	var yanSigned = true;
	  	var marketingSubscribeHuan = true;
	  	var marketingSubscribeTui = true;
	  	var marketingSubscribeChangeName=true;
	  
	  	if(processFlag=="false"){
	  		//更名
	  		if(Ext.Array.contains(idata,"marketing:subscribe:changeName")){
	  			//审核通过 并且业务状态为(认购|更名|延期签约) 
	  			if(auditStatus=="3" && (businessStatus=="1" || businessStatus=="4" || businessStatus=="6")){
	  				marketingSubscribeChangeName=false;
	  			}
	  			
	  		}
	  		//收款按钮
		  	if(Ext.Array.contains(idata,"marketing:subscribe:receivables")){
		  		//显示条件 审核通过、收款未完成 、(认购|更名) 
				if(auditStatus=="3"&& shouStatus=="0" && (businessStatus=="1" || businessStatus=="4" || businessStatus=="6")){
					marketingSubscribeReceivables = false;
				}
			}
		  	//收款明细 
		  	if(Ext.Array.contains(idata,"marketing:subscribe:receivablesDetail")){
		  		//显示条件:审核通过 并且存在收款记录
		  		if(auditStatus=="3" && amountDetail=="1"){
		  			marketingSubscribeShou = false;
				}
		  	}
		  	//换房
			if(Ext.Array.contains(idata,"marketing:subscribe:changeHouse")){
				//显示条件:审核通过 并且业务状态为认购或者更名
				if(auditStatus=="3" &&(businessStatus=="1" || businessStatus=="4" || businessStatus=="6")){
					marketingSubscribeChangeHouse=false;
				}
			}
		  	//签约
			if(Ext.Array.contains(idata,"marketing:signed:add")){
				//显示条件:审核通过&&房间状态为认购&&延期签约状态为否&&业务状态为认购或者更名
				if(auditStatus=="3" && roomStatus=="4" && yanqiStatus=="1"  && (businessStatus=="1" || businessStatus=="4" || businessStatus=="6")){
					marketingSignedAdd = false;
				}
			}
		  	//退认购
			if(Ext.Array.contains(idata,"marketing:subscribe:cancel")){
				//显示条件:审核通过 &&房间状态为认购 &&业务状态为认购或者更名
				if(auditStatus=="3" && roomStatus=="4" && (businessStatus=="1" || businessStatus=="4" || businessStatus=="6")){
					tuiSubscribe = false;
				}
			}
		  	//延期签约
			if(Ext.Array.contains(idata,"marketing:subscribe:delaySigned")){
				//显示条件:审核通过  &&业务状态为认购或者更名
				if(auditStatus=="3" && (businessStatus=="1" || businessStatus=="4") ){
					yanSigned = false;
				}
			}
			if(businessStatus=="3"){
				marketingSubscribeHuan=false;
			}else{
				marketingSubscribeHuan=true;
			}
			if(businessStatus=="5"){
				marketingSubscribeTui=false;
			}else{
				marketingSubscribeTui=true;
			}
	  	}
		
    </script>
</head>
<script type="text/javascript">

function autoStatusCn(auditStatus){
		if(auditStatus == "0"){
			return "<font style='color: red;'>待提交</font>";
		}else if(auditStatus == "1"){
			return  "<font style='color: red;'>审核中</font>";
		}else if(auditStatus == "2"){
			return "<font style='color: red;'>已退回</font>";
		}else if(auditStatus == "3"){
			return "<font style='color: red;'>已通过</font>";
		}
	}

Ext.onReady(function() {
	var viewPanel=Ext.create("customer.subscribe.viewPanel");
 	var estateRecord=${estateRecord};
 	var customerRecord=${customerRecord}; 
 	var subscribeRecord=${subscribeRecord}; 
 	projectId = subscribeRecord.projectId;
	//初始化值
	viewPanel.getComponent("estatePanel").getForm().setValues(estateRecord);
 	viewPanel.getComponent("customerPanel").getForm().setValues(customerRecord);
 	viewPanel.getComponent("subscribeInfoForm").getForm().setValues(subscribeRecord); 
 	if(subscribeRecord.floorType=="1"){
 	  	Ext.getCmp('discountAfterPrice').setVisible(false);
 	}
 	
 	//审核历史,展示当前审核状态
 	if(auditStatus!=null&&auditStatus!=""){
 		var currAutidStatus = autoStatusCn(auditStatus);
 		//Ext.getCmp("currAuditStatus").setValue(currAutidStatus);
 	}
 	//折扣信息
 	if(busAutoStatus!=null&&busAutoStatus!=""){
 		var busAutoStatusCN = autoStatusCn(busAutoStatus);
 		Ext.getCmp("AppcurrAuditStatus").setValue(busAutoStatusCN);
 	}
 	
 	if(processFlag=="true" || processFlag==true){
 		Ext.getCmp("retrunBtn").setVisible(false);
 		//审批历史隐藏
 		Ext.getCmp("historyPanel").setVisible(false);
 		Ext.getCmp("historyAppreovalPanel").setVisible(false);
 		//Ext.getCmp("haveReceiveBtn").setVisible(false);
 		
 	}  
  	var back = "${back}";
  	if(back=="error"){
  		Ext.getCmp("retrunBtn").setVisible(false);
    }else{
    	Ext.getCmp("retrunBtn").setVisible(true);
    }
});
</script>
<body>
</body>
</html>